import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {

    private EditText searchEditText;
    private TextView resultTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // 获取搜索输入框控件
        searchEditText = findViewById(R.id.search_edit_text);
        // 获取结果显示文本控件
        resultTextView = findViewById(R.id.result_text_view);
    }

    public void onSearchClick(View view) {
        String searchTerm = searchEditText.getText().toString();
        // 模拟农产品数据
        String[] agriculturalProducts = {"苹果", "香蕉", "橙子", "西瓜", "葡萄", "草莓", "玉米", "土豆"};

        boolean found = false;
        for (String product : agriculturalProducts) {
            // 判断搜索词是否与农产品匹配
            if (product.equals(searchTerm)) {
                found = true;
                break;
            }
        }

        if (found) {
            // 显示找到的结果
            resultTextView.setText(searchTerm + " 找到了。");
        } else {
            // 显示未找到的结果
            resultTextView.setText(searchTerm + " 未找到。");
        }
    }
}